﻿using System;
using System.Collections;

namespace CymbergajTouch.Logic
{
    enum GoalsToWin
    {
        Seven = 7,
        Nine = 9,
        NoWinner = -1
    }
    /// <summary>
    /// Stores game settings (sound, bonuses etc.).
    /// </summary>
    class Options
    {
        public bool Sound { get; set; }
        public bool Bonuses { get; set; }
        public GoalsToWin GoalsToWinValue { get; set; }

        public Options(bool sound, bool bonuses, GoalsToWin goalsToWinMatch)
        {
            Sound = sound;
            Bonuses = bonuses;
            GoalsToWinValue = goalsToWinMatch;
        }

        /// <summary>
        /// Returns string that represents sound option.
        /// </summary>
        /// <returns>sound option name with its state</returns>
        public String GetSoundOption()
        {
            String result = "Sound (";
            if (Sound)
            {
                result += "on";
            }
            else
            {
                result += "off";
            }

            result += ")";
            return result;
        }

        /// <summary>
        /// Returns string that represents bonuses option.
        /// </summary>
        /// <returns>bonuses option name with its state</returns>
        public String GetBonusesOption()
        {
            String result = "Bonuses (";
            if (Bonuses)
            {
                result += "on";
            }
            else
            {
                result += "off";
            }

            result += ")";
            return result;
        }

        /// <summary>
        /// Returns string that represents option that decides about finishing a match.
        /// </summary>
        /// <returns>goals to win option name with its state</returns>
        public String GetGoalsToWinOption()
        {
            String result = "Goals to win (";
            if (GoalsToWinValue == GoalsToWin.NoWinner)
            {
                result += "no winner";
            }
            else
            {
                result += (int)GoalsToWinValue;
            }
            result += ")";
            return result;
        }

        /// <summary>
        /// Changes sound option.
        /// </summary>
        public void ChangeSound()
        {
            Sound = !Sound;
        }

        /// <summary>
        /// Changes bonuses option.
        /// </summary>
        public void ChangeBonuses()
        {
            Bonuses = !Bonuses;
        }

        /// <summary>
        /// Changes goals to win option.
        /// </summary>
        public void ChangeGoalsToWin()
        {
            switch (GoalsToWinValue)
            {
                case GoalsToWin.Seven:
                    GoalsToWinValue = GoalsToWin.Nine;
                    break;
                case GoalsToWin.Nine:
                    GoalsToWinValue = GoalsToWin.NoWinner;
                    break;
                case GoalsToWin.NoWinner:
                    GoalsToWinValue = GoalsToWin.Seven;
                    break;
            }
        }
    }
}
